package InterviewTest.q0803_findMagicIndex;

public class Solution {
    public int findMagicIndex(int[] nums) {
        int flag = 0;
        while (flag < nums.length) {
            if (nums[flag] == flag) {
                return flag;
            } else if (nums[flag] > flag) {
                flag = nums[flag];
            } else {
                flag++;
            }
        }
        return -1;

    }
}
